package com.boot.mgt.controller.app

import com.boot.core.result.ResultTo
import com.boot.mgt.model.TaLocationReport
import com.boot.mgt.service.TaLocationReportService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

/**
 * @author kawins
 * createTime 2019-03-14 19:35
 */
@RestController
@RequestMapping("/app/location_report")
class TaLocationReportController {


    @Autowired
    private lateinit var taLocationReportService: TaLocationReportService


    @PostMapping
    fun insert(@RequestBody taLocationReport: TaLocationReport): ResultTo {
        taLocationReportService.insert(taLocationReport)
        return ResultTo()
    }

    @PostMapping("/insertRpc")
    fun insertRpc(@RequestBody taLocationReport: TaLocationReport, police_number: String): ResultTo {
        taLocationReportService.insertRpc(taLocationReport, police_number)
        return ResultTo()
    }

    @GetMapping("/all")
    fun selectAll(): ResultTo {
        val list = taLocationReportService.selectAll()
        return ResultTo().setData("data", list)
    }


    @GetMapping
    fun selectByNum(@RequestParam(required = false, defaultValue = "") police_number: String): ResultTo {
        val list = taLocationReportService.selectByNum(police_number)
        return ResultTo().setData("data", list)
    }


}
